<?php

namespace  App\Http\Controllers\V1;

use App\Helpers\RestResponseFactory;
use App\Helpers\RestUtils;
use App\Helpers\Utils;
use App\Http\Controllers\Controller;
use App\Models\Factory\SmsFactory;
use App\Models\Factory\UserFactory;
use App\Models\Orm\Banner;
use App\Models\Orm\Order;
use App\Models\Orm\Send;
use App\Models\Orm\UserApply;
use App\Services\Core\Sms\Dahan\DahanService;
use Illuminate\Http\Request;
/**
 * Class GeetesController
 * @package App\Http\Controllers\V1
 * 短信
 */
class OrderController extends  Controller
{

    /**
     * 发送短信
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function addOrder(Request $request)
    {
        $user = $request -> get('user');
        $data = $request->except('token');
        $data['user_id'] = $user->id;
        $data['average_time'] =  rand(1,60).'分钟';
        $data['time'] =  rand(1,60).'分钟';
        $data['average_money'] =  rand(1,50).'元';
        $data['send_id'] =  rand(1,7);
        $data['send_id'] =  rand(1,7);
        $data['money'] =  rand(1,50);
        $data['created_at'] = date("Y-m-d H:i:s",time());
        $data['updated_at'] = date("Y-m-d H:i:s",time());
        $data['order_id'] = Utils::createNid();
        $datas = Order::create($data);
        return RestResponseFactory::ok(RestUtils::getStdObj(),200);

    }


    public function getOrder(Request $request)
    {
        $user = $request -> get('user');
        $data = $request ->all();
        $datas = Order::where('user_id',$user->id)->where('status',$data['status'])->get();
        return RestResponseFactory::ok($datas,200);

    }







}